package com.bdy.lm.taximanager.util;

/**
 * Created by Administrator on 2016/9/13 0013.
 */

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;

import com.bdy.lm.taximanager.ui.LoginActivity;

import java.util.Date;

public class AutoStartReceiver extends BroadcastReceiver {
    private SharedPreferences.Editor editor;
    private SharedPreferences sharedPreferences;

    public void onReceive(Context paramContext, Intent paramIntent) {
        Intent intent = new Intent(paramContext, LoginActivity.class);
        intent.setFlags(268435456);
        paramContext.startActivity(intent);
        sharedPreferences = paramContext.getSharedPreferences("TemptData", Context.MODE_PRIVATE);
        editor = sharedPreferences.edit();
        editor.putString("开机时间String", TimeUtils.getFormatTime());
        editor.putLong("开机时间Unix", new Date().getTime());
        editor.commit();
    }

    public static long getUpTimeSeconds(Activity paramActivity) {
        return paramActivity.getSharedPreferences("TemptData", Context.MODE_PRIVATE).getLong("开机时间Unix", new Date().getTime());
    }

    public static String getUpTimeString(Activity paramActivity) {

        return paramActivity.getSharedPreferences("TemptData", Context.MODE_PRIVATE).getString("开机时间String", null);
    }


}
